import {getUser,logout} from '../../assets/js/request.js'
const state = {
    userInfo:JSON.parse(localStorage.getItem('loginInfo')) || []
}
const mutations = {
    setUserInfo(state,data) {
        state.userInfo = data
    },
    setSignOut(state) {
        state.userInfo = {}
        localStorage.setItem('token','')
    }
}
const actions = {
    async getUserInfo({commit}) {
        let res = await getUser()
        console.log(res);
        commit('setUserInfo',res)
    },
    async signOut({commit}) {
        await logout()
        commit('setSignOut')
    }
}
const getters = {
    
}
export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters,
}